package com.example.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Random;

@RestController
public class FirstController {
    @GetMapping("/hello")
    public String hello(){
        return "hello world";
    }

    @GetMapping("/random")
    public String Random(Model model){
        Random rd=new Random();
        model.addAttribute("Result",new Result(0,rd.nextInt(1000),"生成随机数成功"));
        return "Randoms";
    }

    @RequestMapping("/square/4")
    public int Square(){
        return 16;
    }
}